package org.example.backend.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.backend.common.Result;
import org.example.backend.dto.VideoDTO;
import org.example.backend.service.CategoryService;
import org.example.backend.service.VideoChunkService;
import org.example.backend.service.VideoService;
import org.example.backend.utils.MinioUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @author 啊昌
 * @date 2025/7/20 11:05
 * VideoController 视频
 */
@Tag(name = "视频管理")
@RestController
public class VideoController {
	@Autowired
	private VideoService videoService;

	@Autowired
	private VideoChunkService videoChunkService;


	@GetMapping("/getAllVideo")
	@Operation(summary = "获取所有的视频")
	public Result<Map<String, Object>> getAllVideo() {
		Result<Map<String, Object>> allVideo = videoService.getAllVideo();
		return allVideo;
	}


	@PostMapping("/uploadVideo")
	@Operation(summary = "上传视频")
	public Result<Map<String, Object>> uploadVideo(@RequestParam("file") MultipartFile file) throws Exception {
		//todo 这里只能出来视频类型的、照片这种类型上传还是有问题
		Result<Map<String, Object>> result = videoService.uploadVideo(file);
		return result;
	}

	@PostMapping("/MQuploadVideo")
	@Operation(summary = "上传视频")
	public Result<Map<String, Object>> MQuploadVideo(@RequestParam("file") MultipartFile file) throws Exception {
		//todo 这里只能出来视频类型的、照片这种类型上传还是有问题
//		videoChunkService.saveVideoChunks();
		return null;
	}


	@PostMapping("/uploadVideoMessages")
	@Operation(summary = "上传视频和消息")
	public Result<Map<String, Object>> uploadVideoMessages(@RequestBody VideoDTO videoDTO) throws Exception {
		Result<Map<String, Object>> result = videoService.uploadVideoMessages(videoDTO);
		return result;
	}

}
